<html>
<head>
<link href="css/qam.css" rel="stylesheet" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
.margin_left{margin-left:80px;}
</style>
</head>
<body>

	<div style="width:960px;margin:0 auto">
		<div id="message" ></div>
		
		<HR><h3>组件管理</h3>
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;">
			<form method="post" action="#" name="myform" class="myform">
				<input type="hidden" value="" name="id" />
				<label><span>组件名称：</span><input type="text" value="" name="name" /></label><BR />
				<label><span>组件描述</span><input type="text" value="" name="info" /></label><BR />
				<label><span>所属项目</span><div id="parent_box"></div></label><span id="ident"></span><span id="ident_txt"></span><BR />
				
				<div id="code_textarea">
					<label><span>html代码：</span></label><textarea name="html" class="html"></textarea><BR />
					<div class="margin_left"><span id="html_image_status"></span></div>
					<label><span>css代码：</span></label><textarea name="css" class="css"></textarea><BR />
					<div class="margin_left"><span id="css_image_status"></span></div>
					<label><span>js代码：</span></label><textarea name="js" class="js"></textarea><BR />
					<input type="button" value="分析" onclick="analysis_html();" /><input type="button" value="添加" onclick="add();" name="button"  />
				</div>
				<div id="code_div" style="display:none">
					<label><span>html代码：</span></label><div id="html" class="html"></div><BR />
					<label><span>css代码：</span></label><div id="css" class="css"></div><BR />
					<label><span>js代码：</span></label><div id="js" class="js"></div><BR />
				</div>
				
				
			</form>
		</div>
		
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;display:none" id="image_box">
				<input type="hidden" id="image_id" value="" />
				<input type="hidden" id="src_present_base64" value="" />
				类型：<select id="image_type"><option value="0">碎图</option><option value="1">非碎图</option><option value="2">效果图</option></select>
				碎图：在slice目录下，最终生成雪碧图 | 非碎图：不生成雪碧图，但会被提单 | 效果图：不会被提单，建议用效果图生成页面<BR>
				原始图片：<input type="text" id="src_origin" value="" />
				引用图片：<input type="text" id="src_present" value="" style="display:none"  /> <input type="file" id="src_file" size="10" multiple="true" onchange="imagesSelected(this.files)" />
				<input type="button" value="保存" id="image_button" onclick="pick_add_image()" />
		</div>
		
		
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;display:none" id="pick_box">
			<input type="hidden" id="pick_id" value="" />
			<input type="hidden" id="code_id" value="" />
			<input type="hidden" id="pick_index" value="" />
			组：<input type="text" id="pick_group" value="通用" />
			标题：<input type="text" id="name" value="" />
			说明：<input type="text" id="info" value="" /><BR>
			<label id="selector_box">选择器：<input type="text" id="selector" value="" /></label>
			属性：<input type="text" id="property" value="" />
			默认值：<input type="text" id="value" value="" />
			
			<input type="button" value="保存" id="pick_button" onclick="pick_html_add()" />
			<BR>
			
		</div>
		

		<div style="padding:10px;background:#E8E8FF;margin-top:10px;display:none" id="image_listbox"></div>
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;display:none" id="pick_listbox"></div>
		<form name="search_form" class="search_form">
			<label>名称<input type="text" value="" name="name" /></label>
			<label>描述<input type="text" value="" name="info" /></label>
			<label>所属项目<span id="search_parent_box"></span></label>
			<label><input type="button" value="搜索" name="search_btn" onclick="search(0)" /></label><BR><BR>
			<label>模糊查找<input type="text" value="" name="search_data" /></label>(关键字用空格分开)
			<label><input type="button" value="搜索" name="search_btn" onclick="search(1)" /><input type="button" value="重置" name="search_btn" onclick="search_clear()" /></label>
			
		</form>
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;" id="listbox"></div>
		
		

	</div>

	
	<div id="shade_layer">
		<div class="shade_layer_transparent"></div>
		<iframe src="" id="shade_frame"></iframe>
	</div>

</body>

<script src="js/ajax.js" type="text/javascript"></script>
<script src="js/md5.js" type="text/javascript"></script>
<script src="js/function.js" type="text/javascript"></script>
<script>


function init(){load_project_list();}

function shade_layer_show(t){
	$$("shade_frame").src="img_adjust.htm?"+t;
	$$("shade_layer").style.display="block";
	$$("shade_layer").style.width=document.body.clientWidth;
	$$("shade_layer").style.height=document.body.clientHeight;
}

function shade_layer_close(){
	$$("shade_layer").style.display="none";
}


/*****preview ********/
function preview_htm(t){
	var page_src=cgipath+t;
	window.open(page_src);
}

function preview_img(t){
	shade_layer_show(t);
	return;
}



//提取html设置
function pick_html(t){
	$$("pick_button").value="保存";
	$$("pick_button").onclick=Function("pick_html_add()");
	$$("pick_box").style.display="block";
	$$("image_box").style.display="none";
	$$("selector_box").style.display="none";
	$$("code_id").value=document.myform.id.value;
	$$("property").value=t;
}

//保存html设置
function pick_html_add(t){
	var _url=cgipath+"pick-addHtml";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_html_add,handle_error,5000);
	ajax_obj.postData("&name="+$$("name").value+"&pick_group="+$$("pick_group").value+"&info="+$$("info").value+"&code_id="+$$("code_id").value+"&property="+$$("property").value+"&value="+$$("value").value);
}

function handle_pick_html_add(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	pick_showlist();
	print(document.myform.id.value);
}


/*****pick edit html********/
function pick_edit_html(t){
	$$("pick_box").style.display="block";
	$$("selector_box").style.display="none";
	var _url=cgipath+"pick-getinfo";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_edit_html,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_pick_edit_html(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	$$("property").value=ret_json.record.property;
	$$("value").value=ret_json.record.value;
	$$("pick_group").value=ret_json.record.pick_group;
	$$("name").value=ret_json.record.name;
	$$("info").value=ret_json.record.info;
	$$("pick_id").value=ret_json.record.id;
	$$("code_id").value=ret_json.record.code_id;
	$$("pick_button").value="修改";
	$$("pick_button").onclick=Function("pick_update_html("+ret_json.record.id+")");
}


/*****pick update html********/
function pick_update_html(){
	var _url=cgipath+"pick-updateHtml";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_update_html,handle_error,5000);
	ajax_obj.postData("&id="+$$("pick_id").value+"&name="+$$("name").value+"&pick_group="+$$("pick_group").value+"&info="+$$("info").value+"&code_id="+$$("code_id").value+"&property="+$$("property").value+"&value="+$$("value").value);
}
function handle_pick_update_html(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	pick_showlist();
	print(document.myform.id.value);
}

//html5 选择图片
function imagesSelected(myFiles) {
  for (var i = 0, f; f = myFiles[i]; i++) {
    var imageReader = new FileReader();
    imageReader.onload = (function(aFile) {
      return function(e) {
        document.getElementById('src_present_base64').value=e.target.result;
		document.getElementById('src_present').value=$$("src_file").files[0].name;
      };
	  
    })(f);
    imageReader.readAsDataURL(f);
  }
}

//提取图片
function pick_image(t){
	$$("image_button").value="保存";
	$$("image_button").onclick=Function("image_add()");
	$$("image_box").style.display="block";
	$$("src_present").style.display="none";
	$$("pick_box").style.display="none";
	$$("src_origin").disabled="";
	$$("src_origin").value=t;
	$$("src_origin").disabled="disabled";
	$$("image_type").options[0].selected = true;  
}


//保存图片
function image_add(){
	var _url=cgipath+"image-add";
	var ajax_obj=new AJAX_OBJ(_url,handle_image_add,handle_error,5000);
	ajax_obj.postData("&code_id="+document.myform.id.value+"&src_present="+encodeURIComponent($$("src_present_base64").value)+"&image_type="+$$("image_type").value+"&src_origin="+$$("src_origin").value);
}

function handle_image_add(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	image_showlist();
	print(document.myform.id.value);
}


/*****image edit ********/
function image_edit(t){
	$$("image_button").value="修改";
	$$("image_button").onclick=Function("image_update()");
	$$("image_box").style.display="block";
	$$("src_present").style.display="inline-block";
	var _url=cgipath+"image-getinfo";
	var ajax_obj=new AJAX_OBJ(_url,handle_image_edit,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_image_edit(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("src_origin").disabled="";
	$$("src_origin").value=ret_json.record.src_origin;
	$$("src_origin").disabled="disabled";
	$$("image_id").value=ret_json.record.id;
	for(var i=0;i<$$("image_type").options.length;i++)  
	{  
		if($$("image_type").options[i].value == ret_json.record.type)  
		{  
			$$("image_type").options[i].selected = true;  
			break;  
		}  
	}      
	$$("src_present").value=ret_json.record.src_present;
	
	
	$$("image_button").value="修改";
	$$("image_button").onclick=Function("image_update()");
}


/*****image update********/
function image_update(){
	var _url=cgipath+"image-update";
	var ajax_obj=new AJAX_OBJ(_url,handle_image_update,handle_error,5000);
	ajax_obj.postData("&id="+$$("image_id").value+"&src_present="+encodeURIComponent($$("src_present_base64").value)+"&image_type="+$$("image_type").value);
}
function handle_image_update(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	image_showlist();
	print(document.myform.id.value);
}




/*****image del********/
function image_del(t){
	var _url=cgipath+"image-del";
	var ajax_obj=new AJAX_OBJ(_url,handle_image_del,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_image_del(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	image_showlist();
	print(document.myform.id.value);
}

/*****image list********/
var image_page=1;//第1页
var image_reqnum=10;//每页显示10条
var image_order="id";//排序字段
var image_desc="1";//反序,0或空正常排序，1反序
var image_page_nums=0;

function image_showlist(){
	$$("image_listbox").style.display="block";
	var _url=cgipath+"image-showlist";
	var ajax_obj=new AJAX_OBJ(_url,handle_image_showlist,handle_error,5000);
	ajax_obj.postData("&code_id="+document.myform.id.value+"&page="+image_page+"&reqnum="+image_reqnum+"&order="+image_order+"&desc="+image_desc);
}

function handle_image_showlist(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	var str="<table><thead><tr><td colspan=6>图片列表</td></tr><tr>";
	str+="<td><a href='javascript:image_order=\"id\";image_desc=bin_exchange(image_desc);image_list_page(0)'>序号</a></td>";
	str+="<td><a href='javascript:image_order=\"type\";image_desc=bin_exchange(image_desc);image_list_page(0)'>类型</a></td>";
	str+="<td><a href='javascript:image_order=\"src_origin\";image_desc=bin_exchange(image_desc);image_list_page(0)'>原路径</a></td>";
	str+="<td><a href='javascript:image_order=\"src_present\";image_desc=bin_exchange(image_desc);image_list_page(0)'>当前路径</a></td>";
	str+="<td><a href='javascript:image_order=\"valid\";image_desc=bin_exchange(image_desc);image_list_page(0)'>有效性</a></td>";
	str+="<td>操作</td></tr></thead>";
	for(var i=0;i<ret_json.listdata.length;i++){
		type_str="碎图";
		if(ret_json.listdata[i].type==1)type_str="非碎图";
		else if(ret_json.listdata[i].type==2)type_str="效果图";
		str+="<td>"+((page-1)*reqnum+i+1)+"</td>";
		str+="<td>"+type_str+"</td>";
		str+="<td>"+ret_json.listdata[i].src_origin+"</td>";
		str+="<td>"+ret_json.listdata[i].src_present+"</td>";
		str+="<td>"+ret_json.listdata[i].valid+"</td>";
		str+="<td><a href='#' onclick='image_edit("+ret_json.listdata[i].id+")'>修改</a><a href='#' onclick='image_del("+ret_json.listdata[i].id+")'>删除</a></td></tr>";
	}
	image_page_nums=Math.ceil(ret_json.nums/reqnum);
	str+="<tr><td colspan=5>共"+ret_json.nums+"条，每页"+reqnum+"条，"+page+"/"+image_page_nums+"</td>";
	str+="<td><a href='#' onclick='image_list_page(-1)'>上一页</a><a href='#' onclick='image_list_page(1)'>下一页</a></td></tr>";
	str+="</table>";
	$$("image_listbox").innerHTML=str
}


function image_list_page(t){
	page=page-(-1)*t;
	if(page<=0)page=1;
	else if(page>image_page_nums) page=image_page_nums;
	image_showlist();
}




//提取css设置
function pick_css(t){
	$$("pick_button").value="保存";
	$$("pick_button").onclick=Function("pick_add_css()");
	$$("pick_box").style.display="block";
	$$("selector_box").style.display="inline-block";
	$$("image_box").style.display="none";
	var _url=cgipath+"pick-parse";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_css,handle_error,5000);
	ajax_obj.postData(("&id="+document.myform.id.value+"&pick_index="+t));
}

function handle_pick_css(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("selector").value=ret_json.pick_css.selector;
	$$("property").value=ret_json.pick_css.property;
	$$("value").value=ret_json.pick_css.value;
	$$("code_id").value=ret_json.pick_css.id;
	$$("pick_index").value=ret_json.pick_css.pick_index;
}

//保存css设置
function pick_add_css(t){
	var _url=cgipath+"pick-addCss";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_addCss,handle_error,5000);
	ajax_obj.postData("name="+$$("name").value+"&pick_group="+$$("pick_group").value+"&info="+$$("info").value+"&code_id="+$$("code_id").value+"&pick_index="+$$("pick_index").value+"&selector="+$$("selector").value+"&property="+$$("property").value+"&value="+$$("value").value);
}

function handle_pick_addCss(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	pick_showlist();
	print(document.myform.id.value);
}



/*****pick edit css********/
function pick_edit_css(t){
	$$("pick_box").style.display="block";
	$$("selector_box").style.display="inline-block";
	var _url=cgipath+"pick-getinfo";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_edit_css,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_pick_edit_css(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	$$("selector").value=ret_json.record.selector;
	$$("property").value=ret_json.record.property;
	$$("value").value=ret_json.record.value;
	$$("pick_group").value=ret_json.record.pick_group;
	$$("name").value=ret_json.record.name;
	$$("info").value=ret_json.record.info;
	$$("pick_id").value=ret_json.record.id;
	$$("code_id").value=ret_json.record.code_id;
	$$("pick_index").value=ret_json.record.pick_index;
	
	$$("pick_button").value="修改";
	$$("pick_button").onclick=Function("pick_update_css("+ret_json.record.id+")");
}


/*****pick update css********/
function pick_update_css(){
	var _url=cgipath+"pick-updateCss";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_update_css,handle_error,5000);
	ajax_obj.postData("&id="+$$("pick_id").value+"&name="+$$("name").value+"&pick_group="+$$("pick_group").value+"&info="+$$("info").value+"&code_id="+$$("code_id").value+"&pick_index="+$$("pick_index").value+"&selector="+$$("selector").value+"&property="+$$("property").value+"&value="+$$("value").value);
}
function handle_pick_update_css(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	pick_showlist();
	print(document.myform.id.value);
}


/*****pick del********/

function pick_del(t){
	var _url=cgipath+"pick-del";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_del,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_pick_del(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	pick_showlist();
	print(document.myform.id.value);
	
}





/*****pick list********/
var pick_page=1;//第1页
var pick_reqnum=10;//每页显示10条
var pick_order="id";//排序字段
var pick_desc="1";//反序,0或空正常排序，1反序
var pick_page_nums=0;

function pick_showlist(){
	$$("pick_listbox").style.display="block";
	var _url=cgipath+"pick-showlist";
	var ajax_obj=new AJAX_OBJ(_url,handle_pick_showlist,handle_error,5000);
	ajax_obj.postData("&code_id="+document.myform.id.value+"&page="+pick_page+"&reqnum="+pick_reqnum+"&order="+pick_order+"&desc="+pick_desc);
}

function handle_pick_showlist(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	var str="<table><thead><tr><td colspan=11>pick列表</td></tr><tr>";
	str+="<td><a href='javascript:pick_order=\"type\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>类型</a></td>";
	str+="<td><a href='javascript:pick_order=\"id\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>序号</a></td>";
	str+="<td><a href='javascript:pick_order=\"pick_index\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>pick_index</a></td>";
	str+="<td><a href='javascript:pick_order=\"pick_group\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>组</a></td>";
	str+="<td><a href='javascript:pick_order=\"name\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>名称</a></td>";
	str+="<td><a href='javascript:pick_order=\"info\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>说明</a></td>";
	str+="<td><a href='javascript:pick_order=\"selector\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>选择器</a></td>";
	str+="<td><a href='javascript:pick_order=\"property\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>属性</a></td>";
	str+="<td><a href='javascript:pick_order=\"value\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>默认值</a></td>";
	str+="<td><a href='javascript:pick_order=\"valid\";pick_desc=bin_exchange(pick_desc);pick_list_page(0)'>有效性</a></td>";
	str+="<td>操作</td></tr></thead>";
	for(var i=0;i<ret_json.listdata.length;i++){
		var type_str="html";
		if(ret_json.listdata[i].type==0)type_str="css";
		str+="<tr><td>"+type_str+"</td>";
		str+="<td>"+((page-1)*reqnum+i+1)+"</td>";
		str+="<td>"+ret_json.listdata[i].pick_index+"</td>";
		str+="<td>"+ret_json.listdata[i].pick_group+"</td>";
		str+="<td>"+ret_json.listdata[i].name+"</td>";
		str+="<td>"+ret_json.listdata[i].info+"</td>";
		str+="<td>"+ret_json.listdata[i].selector+"</td>";
		str+="<td>"+ret_json.listdata[i].property+"</td>";
		str+="<td>"+ret_json.listdata[i].value+"</td>";
		str+="<td>"+ret_json.listdata[i].valid+"</td>";
		if(ret_json.listdata[i].type==0)
			str+="<td><a href='#' onclick='pick_edit_css("+ret_json.listdata[i].id+")'>修改</a><a href='#' onclick='pick_del("+ret_json.listdata[i].id+")'>删除</a></td></tr>";
		else
			str+="<td><a href='#' onclick='pick_edit_html("+ret_json.listdata[i].id+")'>修改</a><a href='#' onclick='pick_del("+ret_json.listdata[i].id+")'>删除</a></td></tr>";
	}
	pick_page_nums=Math.ceil(ret_json.nums/reqnum);
	str+="<tr><td colspan=10>共"+ret_json.nums+"条，每页"+reqnum+"条，"+page+"/"+pick_page_nums+"</td>";
	str+="<td><a href='#' onclick='pick_list_page(-1)'>上一页</a><a href='#' onclick='pick_list_page(1)'>下一页</a></td></tr>";
	str+="</table>";
	$$("pick_listbox").innerHTML=str
}


function pick_list_page(t){
	page=page-(-1)*t;
	if(page<=0)page=1;
	else if(page>pick_page_nums) page=pick_page_nums;
	pick_showlist();
}



//获取标识符
function analysis_html(){
	var _url=cgipath+"code-getIdent";
	var ajax_obj=new AJAX_OBJ(_url,handle_analysis_html,handle_error,5000);
	ajax_obj.postData("&html="+encodeURIComponent(document.myform.html.value));
}

function handle_analysis_html(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	if(ret_json.ret==0){
		ident_check(ret_json.ident);
	}
}

//检查标识符是否存在
function ident_check(ident){
	var _url=cgipath+"code-identCheck";
	var ajax_obj=new AJAX_OBJ(_url,handle_ident_check,handle_error,5000);
	var postdata="&ident="+encodeURIComponent(ident);
	ajax_obj.postData("&id="+document.myform.id.value+"&ident="+encodeURIComponent(ident));
}

function handle_ident_check(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	$$("ident").innerHTML=ret_json.ident;
	if(ret_json.ret==0)$$("ident_txt").innerHTML="标识符可以正常添加"
	else $$("ident_txt").innerHTML="标识符已存在"
	
}


var project_data;
/*加载project列表start*/
function load_project_list(){
	var _url=cgipath+"project-showlist";
	var ajax_obj=new AJAX_OBJ(_url,handle_load_project_list,handle_error,5000);
	ajax_obj.postData();
}

function handle_load_project_list(xmlHttp){
	eval("var ret_json="+xmlHttp.responseText);
	var str="<select name=\"project_id\">";
	str+="<option value=\"0\">根目录</option>"
	project_data=ret_json.listdata;
	for(var i=0;i<project_data.length;i++){
		str+="<option value=\""+project_data[i].id+"\" >"+project_data[i].name+"</option>";
	}
	str+="</select>";
	$$("parent_box").innerHTML=str;
	handle_load_project_list_search(xmlHttp);
}

function handle_load_project_list_search(xmlHttp){
	eval("var ret_json="+xmlHttp.responseText);
	var str="<select name=\"project_id\">";
	str+="<option value=\"\">请选择</option>"
	str+="<option value=\"0\">根目录</option>"
	project_data=ret_json.listdata;
	for(var i=0;i<project_data.length;i++){
		str+="<option value=\""+project_data[i].id+"\" >"+project_data[i].name+"</option>";
	}
	str+="</select>";
	$$("search_parent_box").innerHTML=str;
	showlist();
}
/*加载group列表end*/



/*****print code********/
function print(t){
	$$("code_textarea").style.display="none";
	$$("code_div").style.display="block";
	var _url=cgipath+"code-printCode";
	var ajax_obj=new AJAX_OBJ(_url,handle_print,handle_error,5000);
	ajax_obj.postData("&id="+t+"&table=component");
}
function handle_print(xmlHttp){

	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	document.myform.id.value=ret_json.content.id;
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;

	$$("html").innerHTML="<pre>"+ret_json.content.html+"</pre>";
	$$("css").innerHTML="<pre>"+ret_json.content.css+"</pre>";
	$$("js").innerHTML="<pre>"+ret_json.content.js+"</pre>";
	pick_showlist();
	image_showlist();
}


/*****component add********/
function add(){
	var _url=cgipath+"code-add";
	var ajax_obj=new AJAX_OBJ(_url,handle_add,handle_error,5000);
	ajax_obj.postData(formToString(document.myform)+"&type=2&ident="+encodeURIComponent($$("ident").innerHTML));
}
function handle_add(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	$$("css_image_status").innerHTML=img_text_result(ret_json.img_status);
	showlist();
}


/*****component getinfo********/
function edit(t){
	$$("code_div").style.display="none";
	$$("code_textarea").style.display="block";
	var _url=cgipath+"code-getinfo";
	var ajax_obj=new AJAX_OBJ(_url,handle_edit,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_edit(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	document.myform.id.value=ret_json.record.id;
	document.myform.name.value=ret_json.record.name;
	document.myform.html.innerHTML=ret_json.record.html;
	document.myform.css.innerHTML=ret_json.record.css;
	document.myform.js.innerHTML=ret_json.record.js;
	document.myform.info.value=ret_json.record.info;
	document.myform.info.value=ret_json.record.info;
	var str="<select name=\"project_id\">";
	str+="<option value=\"0\">根目录</option>"

	for(var i=0;i<project_data.length;i++){
		str+="<option value=\""+project_data[i].id+"\"";
		if(project_data[i].id==ret_json.record.project_id)str+=" selected=\"selected\" ";
		str+=">"+project_data[i].name+"</option>";
	}
	str+="</select>";
	$$("parent_box").innerHTML=str
	
	document.myform.button.value="修改";
	document.myform.button.onclick=Function("update("+ret_json.record.id+")");
}


/*****component update********/
function update(){
	var _url=cgipath+"code-update";
	var ajax_obj=new AJAX_OBJ(_url,handle_update,handle_error,5000);
	ajax_obj.postData(formToString(document.myform)+"&ident="+encodeURIComponent($$("ident").innerHTML));
}
function handle_update(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	$$("html_image_status").innerHTML=img_text_result(ret_json.img_status.html);
	$$("css_image_status").innerHTML=img_text_result(ret_json.img_status.css);
	showlist();
}


/*****component del********/

function del(t){
	var _url=cgipath+"code-del";
	var ajax_obj=new AJAX_OBJ(_url,handle_del,handle_error,5000);
	ajax_obj.postData("&id="+t);
}
function handle_del(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	showlist();
}





/*****component list********/
var page=1;//第1页
var reqnum=10;//每页显示10条
var order="id";//排序字段
var desc="1";//反序,0或空正常排序，1反序
var page_nums=0;

/*搜索*/
var search_str="";
function search(t){
	if(t==0){
		search_str="&search_flag=0";
		search_str+=formToString(document.search_form);
	}
	else {
		search_str="&search_flag=1";
		search_str+="&search_data="+encodeURIComponent(document.search_form.search_data.value);
	}
	showlist();
}

function search_clear(){
	formReset(document.search_form);
	search_str="";
	showlist();
}
function showlist(){

	var _url=cgipath+"code-showlist";
	var ajax_obj=new AJAX_OBJ(_url,handle_showlist,handle_error,5000);
	ajax_obj.postData(search_str+"&type=2&page="+page+"&reqnum="+reqnum+"&order="+order+"&desc="+desc);
}

function handle_showlist(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	
	eval("var ret_json="+xmlHttp.responseText);
	var str="<table><thead><tr>";
	str+="<td><a href='javascript:order=\"id\";desc=bin_exchange(desc);list_page(0)'>序号</a></td>";
	str+="<td><a href='javascript:order=\"name\";desc=bin_exchange(desc);list_page(0)'>名称</a></td>";
	str+="<td><a href='javascript:order=\"ident\";desc=bin_exchange(desc);list_page(0)'>标识</a></td>";
	str+="<td><a href='javascript:order=\"project_id\";desc=bin_exchange(desc);list_page(0)'>项目</a></td>";
	str+="<td><a href='javascript:order=\"author\";desc=bin_exchange(desc);list_page(0)'>作者</a></td>";
	str+="<td><a href='javascript:order=\"build_time\";desc=bin_exchange(desc);list_page(0)'>创建时间</a></td>";
	str+="<td><a href='javascript:order=\"adjuster\";desc=bin_exchange(desc);list_page(0)'>最后修改</a></td>";
	str+="<td><a href='javascript:order=\"adjust_time\";desc=bin_exchange(desc);list_page(0)'>最后修改时间</a></td>";
	str+="<td>说明</td>";
	str+="<td>操作</td></tr></thead>";
	for(var i=0;i<ret_json.listdata.length;i++){
		str+="<tr><td>"+((page-1)*reqnum+i+1)+"</td>";
		str+="<td>"+ret_json.listdata[i].name+"</td>";
		str+="<td>"+ret_json.listdata[i].ident+"</td>";
		var parent_str="";
		if(ret_json.listdata[i].project_id==0)parent_str="根目录";
		for(var j=0;j<project_data.length;j++){
			if(project_data[j].id==ret_json.listdata[i].project_id)parent_str=project_data[j].name;;
		}
		str+="<td>"+parent_str+"</td>";
		str+="<td>"+ret_json.listdata[i].author+"</td>";
		str+="<td>"+ret_json.listdata[i].build_time+"</td>";
		str+="<td>"+ret_json.listdata[i].adjuster+"</td>";
		str+="<td>"+ret_json.listdata[i].adjust_time+"</td>";
		str+="<td>"+ret_json.listdata[i].info+"</td>";
		str+="<td><a href='#' onclick=\"preview_htm('"+ret_json.listdata[i].path_htm+"')\">预览页面</a><a href='#' onclick=\"preview_img('"+ret_json.listdata[i].id+"')\">预览图片</a><a href='#' onclick='print("+ret_json.listdata[i].id+")'><BR>设置</a><a href='#' onclick='edit("+ret_json.listdata[i].id+")'>修改</a><a href='#' onclick='del("+ret_json.listdata[i].id+")'>删除</a></td></tr>";
	}
	page_nums=Math.ceil(ret_json.nums/reqnum);
	str+="<tr><td colspan=9>共"+ret_json.nums+"条，每页"+reqnum+"条，"+page+"/"+page_nums+"</td>";
	str+="<td><a href='#' onclick='list_page(-1)'>上一页</a><a href='#' onclick='list_page(1)'>下一页</a></td></tr>";
	str+="</table>";
	$$("listbox").innerHTML=str
}


/*列表翻页*/
function list_page(t){
	page=page-(-1)*t;
	if(page<=0)page=1;
	else if(page>page_nums) page=page_nums;
	showlist();
}

</script>
<script src="js/public.js" type="text/javascript"></script>

</html>